package com.zhuangyuan.cloud.data.entities;

import org.hibernate.annotations.GeneratorType;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.util.StringUtils;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

@Entity
@Table(name = "h_cate")
public class Cate extends BaseEntity {
    @Id
    @GenericGenerator(name = "my-guid",strategy = "com.zhuangyuan.cloud.data.entities.GUIDGenerator")
    @GeneratedValue(generator = "my-guid")
    protected String id;
    @Column
    private String name;
    @Column
    private String shortcut;
    @Column(name = "icon_path")
    private String iconPath;
    @Column
    private String description;
    @Column
    private float price;
    @Column
    private float vipPrice;
    @Column(name = "detail_image_path")
    private String detailImagePaths;
    @Column
    private int appraise;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getShortcut() {
        return shortcut;
    }

    public void setShortcut(String shortcut) {
        this.shortcut = shortcut;
    }

    public String getIconPath() {
        return iconPath;
    }

    public void setIconPath(String iconPath) {
        this.iconPath = iconPath;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public float getPrice() {
        return price;
    }

    public void setPrice(float price) {
        this.price = price;
    }

    public float getVipPrice() {
        return vipPrice;
    }

    public void setVipPrice(float vipPrice) {
        this.vipPrice = vipPrice;
    }

    public String getDetailImagePaths() {
        return detailImagePaths;
    }

    public void setDetailImagePaths(String detailImagePaths) {
        this.detailImagePaths = detailImagePaths;
    }

    public int getAppraise() {
        return appraise;
    }

    public void setAppraise(int appraise) {
        this.appraise = appraise;
    }


    public List<String> getImagePaths(){
        List<String> paths = new ArrayList<>();
        if(StringUtils.hasText(this.detailImagePaths)){
            String[] arr = detailImagePaths.split(";");
            for (String s : arr) {
                if(StringUtils.hasText(s)){
                    paths.add(s);
                }
            }
        }
        return paths;
    }
}
